package edu.qqcui.study.bean;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanInitializationException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * TODO
 *
 * @author cuiqingqiang
 * @version 1.0
 * @date 2021-06-26 15:44
 **/
@Component
public class Dog implements ApplicationContextAware {

	//@Autowired
	private ApplicationContext applicationContext;

	public Dog() {
		System.out.println("Dog constructor");
	}

	/**
	 * 在对象实例化并赋值完属性后调用
	 */
	@PostConstruct
	public void init() {
		System.out.println("Dog @PostConstruct");
	}

	/**
	 * 在容器销毁Bean之前进行调用
	 */
	@PreDestroy
	public void destroy() {
		System.out.println("Dog @PreDestroy");
	}

	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		this.applicationContext = applicationContext;
	}
}
